package kr.co.choongang;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class EmpInsertDAO implements EmpSelectInterface{

	private String driver;
	private String url;
	private String userid;
	private String passwd;
	private String emp_id;
	private String ename;
	private int salary;
	private String depart;
	private Statement stmt;
	private Connection conn; 
	private String sql;
	
	private int num;
	EmpSelectDTO empSelectDTO;
	
	
	public EmpInsertDAO() throws ClassNotFoundException {
		empSelectDTO = new EmpSelectDTO();
		driver = "oracle.jdbc.driver.OracleDriver";
		url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
		userid = "rhkss8";
		passwd = "rlaxodus1";
		Class.forName(driver);
	}
	@Override
	public void setConnection() throws SQLException {
		conn = DriverManager.getConnection(url, userid, passwd);
	}

	
	@Override
	public void setStatement(EmpSelectDTO empSelectDTO) throws SQLException {
		stmt=conn.createStatement();
		sql = "insert into emp(emp_id,ename,salary,depart) values ('"+empSelectDTO.getEmp_id()+"','"+empSelectDTO.getEname()+"','"+empSelectDTO.getSalary()+"','"+empSelectDTO.getDepart()+"')";
		
	}
	@Override
	public ResultSet executeQuerySelect() throws SQLException {
		ResultSet rs=null;
		return rs;
	}
	@Override
	public EmpSelectDTO setSelectResult() throws SQLException {
		
		return null;
	}
	@Override
	public int executeQuery() throws SQLException {
		num = stmt.executeUpdate(sql);
		return num;
	}
	

}
